r = 1 gotcandybag = 1 hobo = 1 SCREEN 12 COLOR 7, 0 CLS DIM SHARED DOOM AS DOUBLE Minutes = 10 Seconds = 0 GameTime = Minutes * 60 + Seconds DIM directions(1 TO 9) AS STRING directions(1) = "WEST" directions(2) = "EAST OR SOUTH" directions(3) = "NORTH OR SOUTH" directions(4) = "NORTH OR EAST" directions(5) = "EAST OR WEST" directions(6) = "EAST OR WEST" directions(7) = "NORTH OR WEST" directions(8) = "WEST OR SOUTH" directions(9) = "EAST" PRINT "" PRINT "" PRINT "Well, wasn't it a wonderful night of trick or treating? You have a bag of" PRINT "candy for doing nothing but knocking on doors and saying three words. God," PRINT "how you love this time of year. You notice just how quickly everyone leaves" PRINT "when the night comes to an end. A chill brushes past you and now it's time" PRINT "to head home." PRINT "" DO: LOOP UNTIL INKEY$ <> "" DOOM = TIMER(0.001) + GameTime 'change this to to desied time for the game to run DO CLS PRINT PRINT PRINT " " PRINT " " PRINT " " PRINT " Trick or Treat? " PRINT " " PRINT " Written by " PRINT " " PRINT " D.B. Taylor" PRINT "" PRINT " Copyright (c) 2015" PRINT "" PRINT SPACE$(38); IF INSTR(directions(r), "NORTH") THEN PRINT "N" ELSE PRINT PRINT "*---------------------------------* "; IF INSTR(directions(r), "WEST") THEN PRINT "W"; ELSE PRINT " "; PRINT " + "; IF INSTR(directions(r), "EAST") THEN PRINT "E"; ELSE PRINT " "; PRINT " *------------------------------------*" PRINT SPACE$(38); IF INSTR(directions(r), "SOUTH") THEN PRINT "S" ELSE PRINT PRINT PRINT "If you are stuck just type HELP." PRINT GOSUB ROOM GOSUB parser LOOP ROOM: IF r = 1 THEN: GOSUB r1 IF r = 2 THEN: GOSUB r2 IF r = 3 THEN: GOSUB r3 IF r = 4 THEN: GOSUB r4 IF r = 5 THEN: GOSUB r5 IF r = 6 THEN: GOSUB r6 IF r = 7 THEN: GOSUB r7 IF r = 8 THEN: GOSUB r8 IF r = 9 THEN: GOSUB r9 RETURN parser: PRINT "> "; cmd$ = GrabInput cmd$ = LTRIM$(RTRIM$(UCASE$(cmd$))) IF cmd$ = "END" OR cmd$ = "QUIT" OR cmd$ = "EXIT" OR cmd$ = "Q" THEN END END IF IF cmd$ = "HELP" OR cmd$ = "H" OR cmd$ = "?" THEN CLS PRINT "HERE ARE SOME BASIC COMMANDS THAT CAN BE USED IN THE GAME..." PRINT PRINT "NORTH, EAST ,SOUTH, AND WEST - MOVE TO AN AVAILABLE LOCATION" PRINT "EXAMINE (OBJECT) - EXAMINE AN OBJECT" PRINT "USE (OBJECT) - USE AN OBJECT" PRINT "TAKE (OBJECT) - TAKE OR MOVE AN OBJECT" PRINT "INVENTORY - VIEW YOUR INVENTORY" PRINT "DRINK - DRINK BEER" PRINT "UNLOCK - UNLOCK DOOR" PRINT "HELP - VIEW THIS SCREEN" PRINT "END - END GAME" PRINT PRINT "PRESS ANY KEY...": SLEEP DO: LOOP UNTIL INKEY$ = "" DO: LOOP UNTIL INKEY$ <> "" END IF IF cmd$ = "INVENTORY" OR cmd$ = "INV" OR cmd$ = "ITEMS" OR cmd$ = "I" THEN CLS PRINT "INVENTORY..." PRINT IF gotcandybag = 1 THEN: PRINT "A heavy bag of candy." PRINT PRINT "PRESS ANY KEY..." DO: LOOP UNTIL INKEY$ = "" DO: LOOP UNTIL INKEY$ <> "" END IF IF cmd$ = "GO NORTH" OR cmd$ = "NORTH" OR cmd$ = "N" THEN IF r = 4 THEN: r = 3: GOTO moved IF r = 3 THEN: r = 2: GOTO moved IF r = 7 THEN: r = 8: GOTO moved END IF IF cmd$ = "GO EAST" OR cmd$ = "EAST" OR cmd$ = "E" THEN IF r = 2 THEN: r = 1: GOTO moved IF r = 9 THEN: r = 8: GOTO moved IF r = 4 THEN: r = 5: GOTO moved IF r = 5 THEN: r = 6: GOTO moved IF r = 6 THEN: r = 7: GOTO moved END IF IF cmd$ = "GO SOUTH" OR cmd$ = "SOUTH" OR cmd$ = "S" THEN IF r = 2 THEN: r = 3: GOTO moved IF r = 3 THEN: r = 4: GOTO moved IF r = 8 THEN: r = 7: GOTO moved END IF IF cmd$ = "GO WEST" OR cmd$ = "WEST" OR cmd$ = "W" THEN IF r = 8 THEN: r = 9: GOTO moved IF r = 7 THEN: r = 6: GOTO moved IF r = 6 THEN: r = 5: GOTO moved IF r = 5 THEN: r = 4: GOTO moved IF r = 1 THEN: r = 2: GOTO moved END IF IF (cmd$ = "SWING BAG") THEN CLS PRINT "You swing it around and around. People stop and stare." DO: LOOP UNTIL INKEY$ = "" DO: LOOP UNTIL INKEY$ <> "" END IF IF (cmd$ = "EXAMINE HOBO") AND r = 9 THEN CLS PRINT "He is quite a smelly human being. His clothes are torn and the stench" PRINT "like he hasn't bathed in three months. He looks crazed and wants your" PRINT "candy. He starts yelling...something about Hitler and Turkey? How odd?" DO: LOOP UNTIL INKEY$ = "" DO: LOOP UNTIL INKEY$ <> "" END IF IF (cmd$ = "EXAMINE CANDY BAG") AND gotcandybag = 1 THEN CLS PRINT "A half filled pillow case. A fine mixture of candy bars, suckers, and" PRINT "a few cans of soda. The award of going out on a cold evening night." DO: LOOP UNTIL INKEY$ = "" DO: LOOP UNTIL INKEY$ <> "" END IF IF (cmd$ = "USE CANDY BAG") AND gotcandybag = 1 AND r = 9 THEN CLS GOTO win: DO: LOOP UNTIL INKEY$ = "" DO: LOOP UNTIL INKEY$ <> "" END IF IF (cmd$ = "GIVE CANDY BAG") THEN CLS GOTO lose: DO: LOOP UNTIL INKEY$ = "" DO: LOOP UNTIL INKEY$ <> "" END IF moved: RETURN r1: PRINT "Spooky decorations fill the windows of the houses. A cold chill" PRINT "fills the air. Such a wonderful night to have Halloween." RETURN r2: PRINT "While you walk down the street, you notice one after another the" PRINT "houses start to go dark, and the fellow candy lovers begin heading" PRINT "home." RETURN r3: PRINT "Soon all the laughter and kids talking quickly fades away into" PRINT "the night." RETURN r4: PRINT "You are standing at the entranceway to another street. You have" PRINT "the feeling of being watched wash over you." RETURN r5: PRINT "Every step you take fills the empty and darkened street with the|" PRINT "sound of your footsteps." RETURN r6: PRINT "In the distance you hear the sound of branches being snapped..." RETURN r7: PRINT "Just another houses away and the clean night air turns to a strong" PRINT "smell of rotten food." RETURN r8: PRINT "Great. You can see your house not far from where your standing. -Thank" PRINT "God.- You say, noticing that your Father remembered to leave the porch" PRINT "light on." RETURN r9: PRINT "Standing before you, stands a man, the sorta man one would expect to" PRINT "see in a horror movie...in the light you notice he's a hobo!" RETURN win: COLOR 2, 0 CLS PRINT "You start muttering some words, words of a great ninja, and " PRINT "since you are dressed as a ninja. The sound of the candy and" PRINT "soda rattling around makes a sound like you wouldn't believe." PRINT "Before you know it, the bag makes contact with the hobo's head" PRINT "and he falls like a ton of bricks. Not wasting a moments time" PRINT "you book it home and enjoy the rest of the night. Good times." PRINT DO: LOOP UNTIL INKEY$ <> "" END lose: COLOR 2, 0 CLS PRINT "You hand your candy over and the hobo snatches it out of your hands" PRINT "and walks away. The stench and him muttering about Thanksgiving" PRINT "being ruined fills the air. Way to go kid. You lost your candy on" PRINT "the most excellent night of the year. Enjoy having no candy...sucker!" PRINT DO: LOOP UNTIL INKEY$ <> "" END FUNCTION GrabInput$ x = POS(0) y = CSRLIN maxwidth = _WIDTH - x PCOPY 0, 1 'make a backup copy of the screen DO k = _KEYHIT i$ = INKEY$ LOOP UNTIL k = 0 AND INKEY$ = "" 'clear the keyboard buffer DO _LIMIT 30 PCOPY 1, 0 LOCATE y, x: PRINT Userinput$ k = _KEYHIT SELECT CASE k CASE 8 Userinput$ = LEFT$(Userinput$, LEN(Userinput$) - 1) CASE 65 TO 90, 97 TO 122, 32 Userinput$ = UCASE$(Userinput$ + CHR$(k)) END SELECT timerleft## = (DOOM - TIMER(0.001)) minutes = timerleft## \ 60 seconds = timerleft## - minutes * 60 LOCATE 2, 32: PRINT USING " ###:##.###"; minutes, seconds IF timerleft## <= 0 THEN GOTO doomed _DISPLAY LOOP UNTIL k = 13 GrabInput$ = Userinput$ _AUTODISPLAY EXIT FUNCTION doomed: CLS PRINT "You get lost finding your way home and now you are one of those kids on" PRINT "the milk carton's. Pity, well at least you didn't lose to a hobo!" _DISPLAY END END SUB